import url from './config'

export default (path, data = {}, method = 'GET') => {
    const req = new Promise((resolve, reject) => {
        wx.request({
            url: url.pro + path,
            data,
            method,
            header: {},
            success: res => {
                resolve(res)
            },
            fail: err => {
                reject(err)
            }
        })
    })
    const token = wx.getStorageSync('uinfo')
    if (data.islogin) {
        if (token) {
            return req
        }
    }
    return req
}